package com.it.you.controller;

import com.it.you.common.annotation.AccessLimit;
import com.it.you.common.aop.EasyLog;
import com.it.you.common.constant.Constant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

@RestController
@Slf4j
public class ControllerTest {

//    @EasyLog
    @RequestMapping("/ma")
    public void test(HttpServletRequest request, HttpServletResponse response) throws Exception{
        response.setCharacterEncoding("utf-8");
//        response.setContentType("utf-8");
        PrintWriter out = response.getWriter();
        out.print("requestBody" +
                "");
        out.close();

//        return "love";
    }

    @AccessLimit(seconds = 5, maxCount = 5, needLogin = true)
    @RequestMapping("/fangshua")
    public String fangshua() {
        return "请求成功";
    }

    @GetMapping("/getConstant")
    public Integer getConstant(){
        return Constant.MAX_SIZE;
    }

    @GetMapping("/setConstant")
    public void setConstant(Integer size){
        Constant.MAX_SIZE = size;
    }

}
